home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / gnu_oleo_1_2_2.lha / oleo-1.2.2 / line.c < prev    next >
C/C++ Source or Header  |  1993-03-03  |  968b  |  57 lines

  1. #include <stdio.h>
  2. #include "global.h"
  3. #include "line.h"
  4.  
  5. void
  6. set_line (line, string)
  7.      struct line *line;
  8.      char *string;
  9. {
  10.   int len;
  11.  
  12.   len = strlen (string);
  13.   if (line->alloc <= len)
  14.     {
  15.       if (len < LINE_MIN)
  16.     len = LINE_MIN;
  17.       else
  18.     len++;
  19.       line->alloc = len + 1;
  20.       if (line->buf)
  21.     line->buf = ck_realloc (line->buf, line->alloc);
  22.       else
  23.     line->buf = ck_malloc (line->alloc);
  24.     }
  25.   strcpy (line->buf, string);
  26. }
  27.  
  28. #ifdef __STDC__
  29. void
  30. sprint_line (struct line *line, char * fmt, ...)
  31. #else
  32. void
  33. sprint_line (line, fmt, va_alist)
  34.      struct line *line;
  35.      char *fmt;
  36.      va_dcl
  37. #endif
  38. {
  39.   va_list iggy;
  40.   int len;
  41.  
  42.   len = strlen (fmt) + 200;
  43.   if (!line->alloc)
  44.     {
  45.       line->buf = ck_malloc (len);
  46.       line->alloc = len;
  47.     }
  48.   else if (line->alloc < len)
  49.     {
  50.       line->buf = ck_realloc (line->buf, len);
  51.       line->alloc = len;
  52.     }
  53.   var_start (iggy, fmt);
  54.   vsprintf (line->buf, fmt, iggy);
  55.   va_end (iggy);
  56. }
  57.